package k.daniel.util;


/**
 * 将指定数据按特殊字符串格式显示
 */
public class FormatUtil {
	public static int H = 3600000;
	public static int m = 60000;
	public static int s = 1000;
	/**
	 * 将以密为单位的长度转化为公里或米为单位的数值
	 *
	 * @param distance 单位为米
	 * @return eg:1200->1.2公里
	 */
	public static String getStringDistance(int distance) {
		
		String temp;
		if (distance > 1000) {
			Double doubleDistance=(double) distance;
			doubleDistance = doubleDistance / 1000;
			
			String kilo = doubleDistance.toString();
			;
			temp = kilo.substring(0, kilo.indexOf(".") + 2) + "公里";

		} else {
			temp = distance + "米";
		}
		return temp;
	}
	/**
	 * 将整型的时间转换成字符串. eg:120 -> 2分
	 * @param time 单位=秒
	 * @return eg:120 -> 2分
	 */
	public static String getStringTime(long time) {
		String temp = "";
		if (time > 3600) {
			temp += time / 3600 + "小时";
			time=time%3600;
		} 
		if (time > 60) {
			temp += time / 60 + "分";
		}

		return temp;
	}
}
